package com.guodx.study.springboot.d05.controller;

import com.guodx.study.springboot.d05.domain.User;
import com.guodx.study.springboot.d05.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class UserController {

    @Autowired
    private UserMapper userMapper;

    @PostMapping(value = "/add")
    public User add(@RequestBody User user){
        userMapper.insert(user);
        return user;
    }

    @GetMapping("/user/{userId}")
    public User getUser(@PathVariable("userId") Long userId){
        return userMapper.selectByPrimaryKey(userId);
    }
}
